package finalproject.controller.commands;

import finalproject.model.player.Player;
import finalproject.view.StringManager;

/**
 * Tha take command
 * @author Buisson Kevin
 *
 */
public class TakeCommand extends Command {

	/**
	 * 
	 * @param player the player issuing the command
	 * @param args the args of the command
	 */
	public TakeCommand(Player player, String[] args)
	{
		super(player, args);
	}

	@Override
	public boolean process()
	{
		// No light
		if (!getPlayer().getCurrentRoom().isLighted())
			StringManager.outPut("canttakeitnolight");
		// No item
		else if (!hasSecondWord())
			StringManager.outPut("noitemtake");
		// Take item
		else if (getPlayer().takeItem(getSecondWord()))
		{
			StringManager.outPut("itemtaken");
			return true;
		}

		// Impossible to take
		StringManager.outPut("canttakeit");
		return false;
	}
}
